<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MainView
 *
 * @author mateusz.ledzewicz
 */
class ViewTrain extends DataScreen{
    //put your code here
        
    public function load() {
        parent::load();
        $this->chooseView('train');
        $rows = '';
        for($i = 1; $i<10;$i++)
        {
            $rows .= $this->loadText('rowparam.html', array('num' => $i));
            
        }
        $this->setVar('rows', $rows);
        
    }
    
    protected function listLoad() {
        $list = '
            <tr>
                <td>Nazwa</td>
                <td>Data</td>
                <td>Instrument</td>
                <td>Ilość danych</td>
                <td>Dane wejściowe</td>
                <td>Dane wyjściowe</td>
                <td>Ilość wejść</td>
                <td>Ilość wyjść</td>
                <td>Akcje</td>
            </tr>';
        
        foreach($this->specialVariables['list'] as $r)
        {
            $instrument = Instrument::loadModel($r->id_instrument)->name;
            $list .= '
            <tr>
                <td>'.$r->name.'</td>
                <td>'.$r->dateTo.'</td>
                <td>'.$instrument.'</td>
                <td>'.$r->number.'</td>
                <td>'.$r->data_in.'</td>
                <td>'.$r->data_out.'</td>
                <td>'.$r->number_in.'</td>
                <td>'.$r->number_out.'</td>
                <td></td>
            </tr>';     

         }
         
         
         $this->setVar('addNewLink', '<a href="?step=train&action=edit">Dodaj nowe</a>');
         $this->setVar('list', $list);
    }
    
    protected function formLoad() {
        $this->setVar('step', 'data');
        $gpwList = '';
        foreach($this->specialVariables['select'] as $gpwInstrument){
            $gpwList .= '<option value="'.$gpwInstrument->id_instrument.'">'.$gpwInstrument->name.'</option>'."\n";
        }
        
        
        $this->setVar('select', $gpwList);
       
        $this->addScript('<script src="resource/js/dataForm.js"></script>');
        $this->addScript('<script src="resource/js/count.js"></script>');
        
    }
  
}

?>
